package com.atguigu01._this;

/**
 * ClassName: UserTest
 * Package: com.atguigu01._this
 * Description:
 *
 * @Author ZY
 * @Create 12:04
 * @Version 1.0
 */
public class UserTest {
    public static void main(String[] args) {

        User u1 = new User("tom",20);
    }

}

class User{
    String name;
    int age;

    public User(){

    }

    public User(String name){
        this();
        this.name = name;
    }

    public User(String name,int age){
        this(name);//如果要使用this()，必须声明在当前方法的首行,且在构造器中最多声明一个
//        this.name = name;
        this.age = age;
    }
}

